﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MPMusicVids
{
    public partial class dlgRename : Form
    {
        private string fullpath = "";

        public dlgRename(string origFilename, string fullpath)
        {
            InitializeComponent();
            txtFilename.Text = origFilename;
            this.fullpath = fullpath;
        }

        private void button1_Click(object sender, EventArgs args)
        {
            int i = fullpath.LastIndexOf('\\');
            string newfile = txtFilename.Text;
            if (txtFilename.Text.Contains('\\'))
                newfile = txtFilename.Text.Substring(txtFilename.Text.LastIndexOf('\\'), txtFilename.Text.Length - txtFilename.Text.LastIndexOf('\\')).Replace("\\", "");
            string newName = fullpath.Substring(0, i) + "\\" + newfile;
            try
            {
                System.IO.File.Move(fullpath, newName);
            }
            catch (Exception e) { }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
